package com.hxkj.controller.article;

import com.hxkj.domain.po.AdvertisementColumn;
import com.hxkj.domain.po.AdvertisementColumnTree;
import com.hxkj.domain.po.Column;
import com.hxkj.domain.po.ColumnTree;
import com.hxkj.service.article.AdvertisementColumnService;
import com.hxkj.service.article.ColumnService;
import com.platform.common.domain.result.ResultDataStruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.concurrent.Callable;

/**
 *广告分类的增删改查
 * @author chenfangzhou 2018/09/14
 */
@RestController
@RequestMapping("/advertisementColumn")
public class AdvertisementColumnController {

    @Autowired
    private AdvertisementColumnService advertisementColumnService;

    /**
    * 新增广告分类
    */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public void saveColumn(@ModelAttribute AdvertisementColumn advertisementColumn) throws Exception{
         advertisementColumnService.saveColumn(advertisementColumn);
    }


    /**
    * 获取广告分类的树结构列表
    */
    @RequestMapping(value = "/getlisttree", method = RequestMethod.POST)
    public Callable<List<AdvertisementColumnTree>> getColumnTreeList(@ModelAttribute AdvertisementColumn advertisementColumn) throws Exception{
        return () -> advertisementColumnService.getColumnTreeList(advertisementColumn);
    }


    /**
     *  删除分类
     */
    @RequestMapping(value = "/remove", method = RequestMethod.POST)
    public void removeColumn(@ModelAttribute AdvertisementColumn advertisementColumn) throws Exception{
        advertisementColumnService.removeColumn(advertisementColumn);
    }

    /**
     * 修改广告分类
     */
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    public void modifyColumn(@ModelAttribute AdvertisementColumn advertisementColumn) throws Exception{
        advertisementColumnService.modifyColumn(advertisementColumn);
    }

    /**
     * 修改广告分类排序
     */
    @RequestMapping(value = "/modifysortnum", method = RequestMethod.POST)
    public void modifySortNum(@RequestParam HashMap<String,Object> map) throws Exception{
        advertisementColumnService.modifySortNum(map);
    }
    /**
     *  根据广告的分类获取整个分类结构
     */
    @RequestMapping(value = "/getTopParentColumn", method = RequestMethod.POST)
    public List<AdvertisementColumn> getTopParentColumn(@ModelAttribute AdvertisementColumn advertisementColumn) throws Exception{
        return advertisementColumnService.getTopParentColumn(advertisementColumn);
    }
}
